<template>
  <div class="home-banner">
    <Slider :data="list" />
  </div>
</template>

<script>
import { onMounted, ref } from 'vue'
// 获取轮播图
import { findBanner } from '@/api/home'
// 将获取轮播图数据抽离出来
const getList = () => {
  const list = ref([])
  const getBannerList = async () => {
    const res = await findBanner()
    // console.log(res)
    list.value = res.result
  }
  onMounted(() => {
    getBannerList()
  })
  return { list }
}
export default {
  name: 'HomeBanner',
  setup () {
    // return是一个对象,因此获取List要解构
    const { list } = getList()
    return { list }
  }
}
</script>

<style scoped lang='less'>
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;
}
</style>
